<template>
	<view class="content">
		<view class="banner">
			<uv-image :src="banner" width="100%" height="auto" mode="widthFix"></uv-image>
		</view>
		<view class="title">会议导航</view>
		<view class="cardView">
			<view class="cardItme" v-for="(item,index) in list" :key="index" @click="openFun(item)">
				<view class="img" v-if="item.img">
					<uv-image :src="item.img" width="100%" height="auto" mode="widthFix"></uv-image>
				</view>
				<view class="text" v-if="item.text">{{ item.text }}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {onLoad, onShow, onHide } from '@dcloudio/uni-app';
	import { ref } from 'vue';

	const banner = ref('https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/WechatIMG299.webp')
	const list = ref([
		{
			'text': '会议通知',
			'url': '/pages/meetingNotice',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/1.webp',
			'type': 1
		}, {
			'text': '基本信息',
			'url': '/pages/baseInformation',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/2.webp',
			'type': 1
		}, {
			'text': '会议日程',
			'url': '/pages/meetingSchedule/index',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/3.webp',
			'type': 1
		}, {
			'text': '角色专家介绍',
			'url': '/pages/expert/index',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/4.webp',
			'type': 1
		}, {
			'text': '照片直播',
			'url': 'https://m.alltuu.com/album/1660546433/?menu=richText',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/5.webp',
			'type': 2
		}, {
			'text': '视频直播',
			'url': 'https://amzptrvzb.vzan.com/live/mk/aggspread/1678520653/88ee2ae1-49c8-11f0-a422-3ce1a17fc6bc?v=1749979165153',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/6.webp',
			'type': 2
		},{
			'text': '鸣谢企业',
			'url': '/pages/enterprise',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/7.webp',
			'type': 1
		}, {
			'text': '视频回放',
			'url': '/pages/map/index',
			'img': 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/8.webp',
			'type': 3
		},{
			"text":"学术检索",
			"url":'/pages/meetingQuery/index',
			"img":'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/3.webp',
			'type': 1
		}
	])

	const openFun = (item) => {
		if(item.type == 3){
			uni.showToast({title:'敬请期待',icon:'none'})
		}else if(item.type == 2){
			window.open(item.url)
		}else{
			console.log(item)
			uni.navigateTo({url: item.url})
		}
	}
	
	//分享函数
	const getWin =  async () => { 
		 const currentUrl = 'https://www.yunyakeji.top/';
		
		 // 请求后端获取签名配置
		const res = await vk.callFunction({
			url: 'client/token/pub/index',
			data: { url: currentUrl } // 传递当前URL
		});
		
		const config = res;
		console.log('config',config)
		// 初始化微信SDK
		jWeixin.config({
			debug: false,
			appId: config.appId,
			timestamp: config.timestamp,
			nonceStr: config.noncestr,
			signature: config.signature,
			jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData','onMenuShareAppMessage','onMenuShareTimeline']
		});
		
		jWeixin.ready(() => {
		    // 自定义“分享给朋友”
			 const shareConfig = {
				title: '2025天津市第四届海河肺癌诊疗新进展学术会议',
				desc: '会议日期：6月21日～22日，会议场地：天津梅江中心皇冠假日酒店', // 分享描述
				link: currentUrl, // 使用当前URL
				imgUrl: 'https://mp-9cd2f666-e017-4f0e-a8b2-2c4583bc29c1.cdn.bspapp.com/WechatIMG192.webp', // 分享图标
			};
			
		    jWeixin.updateAppMessageShareData(shareConfig);
		
		    // 自定义“分享到朋友圈”
		    jWeixin.updateTimelineShareData(shareConfig);
			
			// 兼容旧版API
			  jWeixin.onMenuShareAppMessage(shareConfig);
			  
			  jWeixin.onMenuShareTimeline(shareConfig);
		});
		
		jWeixin.error(err => {
			console.error('微信SDK初始化失败', err);
		});
	}
	
	onLoad(() => {
		getWin()
	})
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		max-width: 750px;
		height: 100vh;
		background: no-repeat center bottom;
		background-size: auto 100%;
		box-sizing: border-box;
		position: relative;
		display: block;
		overflow: hidden;
		margin: 0 auto;
		background-color: #f9fafb;

		.banner {
			width: 100%;
			height: auto;
			margin: 0 auto 48rpx;
		}
		
		
		.title{
			width: 100%;
			height: 56rpx;
			font-family: Roboto, Roboto;
			font-weight: 600;
			font-size: 36rpx;
			color: #1F2937;
			line-height: 56rpx;
			margin-bottom: 34rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			
			&::before{
				content: '';
				width: 8rpx;
				height: 32rpx;
				background: #0052D9;
				border-radius: 4rpx;
				margin-right: 12rpx;
				display: inline-block;
				vertical-align: middle;
			}
			
		}

		.cardView {
			width: 100%;
			height: auto;
			display: flex;
			flex-wrap: wrap;
			margin: 0 auto;
			align-items: center;
			justify-content: center;
			gap: 24rpx;
			
			.cardItme {
				min-width: calc(33% - 26rpx);
				max-width: calc(33% - 26rpx);
				height: auto;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				gap: 8rpx;
				color: #181F43;
				background-color: #fff;
				border-radius: 20rpx;

				.img {
					width: 130rpx;
					height: auto;
				}

				.text {
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: 700;
					font-size: 30rpx;
					line-height: 46rpxx;
					color: #181F43;
					padding-bottom: 14rpx;
				}
			}
		}
	}
</style>